package com.iflytek.aisol.audit.iflytek.strategy.manage.controller;


import com.iflytek.aisol.audit.iflytek.strategy.manage.common.entity.R;
import com.iflytek.aisol.audit.iflytek.strategy.manage.dto.DisLimitConfigDTO;
import com.iflytek.aisol.audit.iflytek.strategy.manage.service.DisLimitConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dis-limit-config")
@Slf4j
@Api(tags = "分布式限流配置管理")
public class DisLimitConfigController {

    @Autowired
    private DisLimitConfigService disLimitConfigService;
    /**
     * 新增分布式限流接口
     */
    @PostMapping
    @ApiOperation(value = "新增分布式限流接口")
    public R<?> add(@RequestBody DisLimitConfigDTO disLimitConfigDTO){
        log.info("插入的数据为：{}", disLimitConfigDTO);
        disLimitConfigService.add(disLimitConfigDTO);
        return R.success();
    }

    /**
     * 修改分布式限流接口
     */
    @PutMapping("/{id}")
    @ApiOperation(value = "dis-limit 修改配置")
    public R<?> update(@PathVariable Long id, @RequestBody DisLimitConfigDTO disLimitConfigDTO){
        disLimitConfigService.update(id,disLimitConfigDTO);
        return R.success();
    }

    /**
     * 删除分布式限流接口
     */
    @DeleteMapping("/{id}")
    @ApiOperation(value = "dis-limit 删除配置")
    public R<?> delete(@PathVariable Long id){
        disLimitConfigService.delete(id);
        return R.success();
    }
}
